<?php
    
  $aux = explode ( '|', isset($_GET['id']) ? $_GET['id'] : '' );
  $PositionUid = str_replace ( '"', '', $aux[0] );
  
  require_once ( PATH_PLUGINS . 'hr' . PATH_SEP . 'class.hr.php');
  $pluginObj = new hrClass ();

  require_once ( "classes/model/HrPositions.php" );
  //if exists the row in the database propel will update it, otherwise will insert.
  $tr = HrPositionsPeer::retrieveByPK( $PositionUid  );
  
  if ( ( is_object ( $tr ) &&  get_class ($tr) == 'HrPositions' ) ) { 
     $fields['POSITION_UID'] = $tr->getPositionUid();
     $fields['DEPARTMENT_ID'] = $tr->getDepartmentId();
     $fields['POSITIONCODE'] = $tr->getPositioncode();
     $fields['POSITIONTITLE'] = $tr->getPositiontitle();
     $fields['TYPEPOSITION_ID'] = $tr->getTypepositionId();
     $fields['ASSIGNMENTAREA_ID'] = $tr->getAssignmentareaId();
     $fields['LOWGRADE_ID'] = $tr->getLowgradeId();
     $fields['HIGHGRADE_ID'] = $tr->getHighgradeId();
     $fields['POSITIONCOMMENT'] = $tr->getPositioncomment();
     $fields['POSITIONDESCRIPTION'] = $tr->getPositiondescription();
     $fields['NUMBEROFWORKDAYS'] = $tr->getNumberofworkdays();
     $fields['STATUS'] = $tr->getStatus();
     $fields['RETIREMENTCODE'] = $tr->getRetirementcode();
     $fields['EEOCATEGORY_ID'] = $tr->getEeocategoryId();
     $fields['CLASSIFICATION_ID'] = $tr->getClassificationId();
  }
  else
    $fields = array();  
  
  $G_MAIN_MENU = 'workflow';
  $G_SUB_MENU = 'hrPositions';
  $G_ID_MENU_SELECTED = '';
  $G_ID_SUB_MENU_SELECTED = '';


  $G_PUBLISH = new Publisher;
  $G_PUBLISH->AddContent('xmlform', 'xmlform', 'hr/hrPositionsEdit', '', $fields, 'hrPositionsSave' );
  G::RenderPage('publish', 'blank');
?>